﻿using System;
using System.Collections.Generic;
using System.Reflection;
using Spring.Context;
using Spring.Context.Support;

namespace WeiSha.Core
{
	// Token: 0x0200000E RID: 14
	public class Business
	{
		// Token: 0x06000059 RID: 89 RVA: 0x00003EB8 File Offset: 0x000020B8
		public static IBusinessDo Do<IBusinessDo>()
		{
			bool flag = !typeof(IBusinessDo).IsInterface;
			if (flag)
			{
				throw new ArgumentException("泛型调用的类不是接口类型。");
			}
			bool flag2 = !typeof(IBusinessInterface).IsAssignableFrom(typeof(IBusinessDo));
			if (flag2)
			{
				throw new ArgumentException("泛型调用的不是系统约定的接口类型。");
			}
			string name = typeof(IBusinessDo).Name;
			IBusinessDo businessDo;
			try
			{
				IApplicationContext context = ContextRegistry.GetContext();
				object @object = context.GetObject(name);
				IBusinessInterface businessInterface = @object as IBusinessInterface;
				object obj = Business.lock_obj;
				lock (obj)
				{
					bool flag4 = !Business._objects.ContainsKey(name);
					if (flag4)
					{
						Business._objects.Add(name, @object);
					}
				}
				businessDo = (IBusinessDo)((object)businessInterface);
			}
			catch (Exception ex)
			{
				string text = "无法构建" + name + "接口的实现，请确定web.config中configuration/spring/objects节的配置正确。更多详情：" + ex.Message;
				throw new Exception(text);
			}
			return businessDo;
		}

		// Token: 0x04000019 RID: 25
		public static string CompileVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

		// Token: 0x0400001A RID: 26
		private static string PlatformVersion = Platform.Version;

		// Token: 0x0400001B RID: 27
		private static Dictionary<string, object> _objects = new Dictionary<string, object>();

		// Token: 0x0400001C RID: 28
		private static readonly object lock_obj = new object();
	}
}
